package cn.openea.perpartner.meily.web.controller;



import cn.openea.perpartner.common.core.web.controller.BaseController;
import cn.openea.perpartner.common.core.web.domain.AjaxResult;
import cn.openea.perpartner.common.core.web.page.TableDataInfo;
import cn.openea.perpartner.meily.web.entity.Clientele;
import cn.openea.perpartner.meily.web.service.IClienteleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (ClienteleServices)表控制层
 *
 * @author Weird077
 * @since 2023-01-11 18:57:21
 */
@Api(tags = "客服管理")
@RestController
@RequestMapping("/clientele")
public class ClienteleController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private IClienteleService clienteleService;

    @ApiOperation("客服列表")
    @PostMapping("/list")
    public TableDataInfo selectList(@RequestBody Clientele clientele) {
        startPage();
        List<Clientele> list = this.clienteleService.selectList(clientele);
        return getDataTable(list);
    }

    @ApiOperation("客服详情")
    @GetMapping("{id}")
    public AjaxResult selectOne(@PathVariable Serializable id) {
        return success(this.clienteleService.getById(id));
    }

    @ApiOperation("新增客服")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody Clientele clientele) {
        return toAjax(this.clienteleService.add(clientele));
    }

    @ApiOperation("修改客服")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody Clientele clientele) {
        return toAjax(this.clienteleService.updateById(clientele));
    }

    @ApiOperation("删除客服")
    @PostMapping("/remove")
    public AjaxResult delete(@RequestBody List<Long> idList) {
        return toAjax(this.clienteleService.removeBatchByIds(idList));
    }

    @ApiOperation("小程序-客服详情")
    @GetMapping("/get/{csId}")
    public AjaxResult selectByCsId(@PathVariable String csId) {
        return success(this.clienteleService.selectByCsId(csId));
    }
    @ApiOperation("小程序-客服列表")
    @PostMapping("/type/list")
    public TableDataInfo selectListByCsType(@RequestBody Clientele clientele) {
        List<Clientele> list = this.clienteleService.selectList(clientele);
        return getDataTable(list);
    }
}

